package com.mysoft.gfyx.clue.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mysoft.gfyx.clue.dao.NewUserDao;
import com.mysoft.gfyx.clue.dao.entity.NewUser;
import com.mysoft.gfyx.clue.service.NewUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class NewUserServiceImp implements NewUserService {

    @Autowired
    private NewUserDao userDao ;

    @Override
    public long GetUserId(String uid) {
        QueryWrapper<NewUser> newUserQueryWrapper = new QueryWrapper<>();
        newUserQueryWrapper.eq("uid", uid);
        newUserQueryWrapper.eq("is_deleted", 0);
        NewUser userEntity = userDao.selectOne(newUserQueryWrapper);
        if (userEntity != null) {
            return userEntity.getId();
        }
        return 0;
    }

    @Override
    public long GetAdminId() {
        QueryWrapper<NewUser> newUserQueryWrapper = new QueryWrapper<>();
        newUserQueryWrapper.eq("account", "admin");
        newUserQueryWrapper.eq("is_deleted", 0);
        NewUser userEntity = userDao.selectOne(newUserQueryWrapper);
        if (userEntity != null) {
            return userEntity.getId();
        }
        return 0;
    }
}
